/*
 * ImgPolozkaEdKeys.java
 *
 * Created on 23. listopad 2002, 13:18
 */

package cz.masa.FotoCAT;
import java.sql.*;

/**
 *
 * @author   Jiri Masnik
 */
public class ImgPolozkaEdKeys extends javax.swing.JPanel {
    private fcaImage fcaIm;
    
    /** Creates new form ImgPolozkaEdKeys */
    public ImgPolozkaEdKeys(fcaImage im) {
        this.fcaIm = im;
        initComponents();
        jList1.setListData(fcaIm.getKeywordsVect(0));
        jList2.setListData(KeyEdit.allKeywords(0));
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList2 = new javax.swing.JList();

        setLayout(new java.awt.GridLayout(0, 2, 5, 5));

        setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(3, 3, 3, 3)));
        jScrollPane1.setBorder(new javax.swing.border.EtchedBorder());
        jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                onVChList1(evt);
            }
        });

        jScrollPane1.setViewportView(jList1);

        add(jScrollPane1);

        jScrollPane2.setBorder(new javax.swing.border.EtchedBorder());
        jList2.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                onVChList2(evt);
            }
        });

        jScrollPane2.setViewportView(jList2);

        add(jScrollPane2);

    }//GEN-END:initComponents

    private void onVChList1(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_onVChList1
        idtext idt = (idtext)jList1.getSelectedValue();
        if(idt == null) return; 
        fcaIm.removeKeyword(idt.id);
        jList1.setListData(fcaIm.getKeywordsVect(0));
    }//GEN-LAST:event_onVChList1

    private void onVChList2(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_onVChList2
        idtext idt = (idtext)jList2.getSelectedValue();
        if(idt == null) return; 
        fcaIm.addKeyword(idt.id);
        jList1.setListData(fcaIm.getKeywordsVect(0));
    }//GEN-LAST:event_onVChList2
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JList jList2;
    private javax.swing.JList jList1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
    
}
